local json = require("cjson")


local cmds = require "cmds"

local green_ip = {["120.27.232.226"]=1,
                  ["218.107.55.252"]=1,
                   ["119.130.106.213"]=1,
                     ["123.57.16.126"]=1,  
                       ["58.56.226.2"]=1, 
                         ["118.31.78.219"]=1, 
                         ["127.0.0.1"]=1, 
                                        
                  
            }

--获取客户端ip
function get_client_ip()
    local headers=ngx.req.get_headers()
    local ip=headers["X-REAL-IP"] or headers["X_FORWARDED_FOR"] or ngx.var.remote_addr or "0.0.0.0"
    return ip
end


local client_ip = get_client_ip()

local args = ngx.req.get_uri_args()

local name = args.name
local head = args.head
local code = args.code

local str = string.format("%s,%s,%s,%s",name,code,os.time(),math.random(1,2000))
local md5 = require "md5"

local redis = require "redis_iresty"
local red = redis:new()

local ok, err = red:set("dog", "an animal")
if not ok then
    ngx.say("failed to set dog: ", err)
    return
end

ngx.say("set result: ", ok)


ngx.say(json.encode(msg))

